//按钮事件新增或编辑
var BCB2C1_type = "";
//其他页面传到本页面参数
var BCB2C1_param = {};
//暂时没用
var BCB2C1_validate = "";
//当前触发按钮
var BCB2C1_btn = "";

/*定义下拉框集合定义*/
/*declare select options begin*/

/*declare select options end*/

//输入框默认值
function BCB2C1_input_default(){
	/*时间格式初始化*/
	/*form datetime init begin*/
    if($("#BCB2C1_SYS_DATE").val() == "")
    {
        $("#BCB2C1_SYS_DATE").val(new Date().Format('yyyy-MM-dd hh:mm:ss'));
    }
    laydate.render({
        elem: '#BCB2C1_SYS_DATE',
        type: 'datetime',
        trigger: 'click'
    });
    if($("#BCB2C1_CREATE_DATE").val() == "")
    {
        $("#BCB2C1_CREATE_DATE").val(new Date().Format('yyyy-MM-dd hh:mm:ss'));
    }
    laydate.render({
        elem: '#BCB2C1_CREATE_DATE',
        type: 'datetime',
        trigger: 'click'
    });
	
    /*form datetime init end*/
	
	//所有输入框设置默认值
	/*Input Default Begin*/

	/*Input Default End*/
}

//主从表传递参数
function BCB2C1_param_set(){
	/*Main Subsuv Table Param Begin*/
	
	/*Main Subsuv Table Param end*/

	/*父页面查询条件参数传递至子页面并赋值*/
	/*Get Find Select param bgein*/
		if(BCB2C1_param.hasOwnProperty("LOGIN_ID"))
        	$("#BCB2C1_LOGIN_ID").val(BCB2C1_param["LOGIN_ID"]);
		if(BCB2C1_param.hasOwnProperty("NICK_NAME"))
        	$("#BCB2C1_NICK_NAME").val(BCB2C1_param["NICK_NAME"]);
		if(BCB2C1_param.hasOwnProperty("SYS_DATE"))
        	$("#BCB2C1_SYS_DATE").val(BCB2C1_param["SYS_DATE"]);
	
	/*Get Find Select param end*/
}

//业务逻辑数据开始
function BCB2C1_t_login_log_biz_start(inputdata) {
	BCB2C1_param = inputdata;
	layer.close(ly_index);
    /*biz begin*/
    BCB2C1_init_t_login_log()
	
    /*biz end*/
}

/*biz step begin*/

/*biz step end*/

/*查找框函数*/
/*find qry fun begin*/

/*find qry fun end*/

/*页面结束*/
function BCB2C1_page_end(){
	page_btn_priv("BCB2C1");
	if(BCB2C1_param["type"] == "edit"){
		BCB2C1_get_edit_info();
	}
}

//页面初始化方法
function BCB2C1_init_t_login_log() {
	//输入框默认值
	BCB2C1_input_default();
	//参数传递
	BCB2C1_param_set();	
	//表单验证
	BCB2C1_checkFormInput();
	//结束函数
	BCB2C1_page_end();
}

//提交表单数据
function BCB2C1_SubmitForm(){
	if(BCB2C1_param["type"] == "add"){
		var inputdata = {
				"param_name": "N01_ins_t_login_log",
				"session_id": session_id,
				"login_id": login_id
	            /*insert param begin*/
                ,"param_value1": s_encode($("#BCB2C1_LOGIN_ID").val())
                ,"param_value2": s_encode($("#BCB2C1_NICK_NAME").val())
                ,"param_value3": s_encode($("#BCB2C1_OPE_IP").val())
                ,"param_value4": $("#BCB2C1_SYS_DATE").val()
                ,"param_value5": s_encode($("#BCB2C1_S_DESC").val())
                ,"param_value6": $("#BCB2C1_CREATE_DATE").val()
				
	            /*insert param end*/
			};
		get_ajax_baseurl(inputdata, "BCB2C1_get_N01_ins_t_login_log");
	}
	else if(BCB2C1_param["type"] == "edit"){
		var inputdata = {
				"param_name": "N01_upd_t_login_log",
				"session_id": session_id,
				"login_id": login_id
	            /*update param begin*/
                ,"param_value1": s_encode($("#BCB2C1_LOGIN_ID").val())
                ,"param_value2": s_encode($("#BCB2C1_NICK_NAME").val())
                ,"param_value3": s_encode($("#BCB2C1_OPE_IP").val())
                ,"param_value4": $("#BCB2C1_SYS_DATE").val()
                ,"param_value5": s_encode($("#BCB2C1_S_DESC").val())
                ,"param_value6": $("#BCB2C1_CREATE_DATE").val()
                ,"param_value7": $("#BCB2C1_MAIN_ID").val()
				
	            /*update param end*/
			};
		get_ajax_baseurl(inputdata, "BCB2C1_get_N01_upd_t_login_log");
	}
}

//vue回调
function BCB2C1_t_login_log_call_vue(objResult){
	if(index_subhtml == "XXXXXX")
	{
		
	}
	/*查询条件弹窗子页面*/
    /*get find subvue bgein*/
	
	/*get find subvue end*/
}

//form表单提交
$("#BCB2C1_save_t_login_log_Edit").click(function () {
	$("form[name='BCB2C1_DataModal']").submit();
})

/*修改数据*/
function BCB2C1_get_N01_upd_t_login_log(input) {
	layer.close(ly_index);
	if (Call_OpeResult(input.N01_upd_t_login_log) == true)
	{
		swal("修改数据成功!", "", "success");
		ACB2C1_t_login_log_query();
		BCB2C1_clear_validate();
		layer.close(BCB2C1_param["ly_index"]);
	}
}

/*添加数据*/
function BCB2C1_get_N01_ins_t_login_log(input) {
	layer.close(ly_index);
	if (Call_OpeResult(input.N01_ins_t_login_log) == true)
	{
		swal("添加数据成功!", "", "success");
		ACB2C1_t_login_log_query();
		BCB2C1_clear_validate();
		layer.close(BCB2C1_param["ly_index"]);
	}
}

//取消编辑
$("#BCB2C1_cancel_t_login_log_Edit").click(function () {
	layer.close(BCB2C1_param["ly_index"]);
	BCB2C1_clear_validate();
	$("[id^='BCB2C1_div']").hide();
})

//清除查找框
function BCB2C1_clear_input_cn_name(obj1,obj2){
	$("#"+obj1).val("");
	$("#"+obj2).val("-1");
}

//清除验证缓存
function BCB2C1_clear_validate(){
	$("#BCB2C1_DataModal").find(".has-error").each(function(){
		$(this).removeClass('has-error');
	});
	$("#BCB2C1_DataModal").find(".has-success").each(function(){
	 	$(this).removeClass('has-success');
	});
	$("#BCB2C1_DataModal").find(".glyphicon").each(function(){
	 	$(this).remove();
	});
}

//输入框重置
function BCB2C1_clear_edit_info(){
	var inputs = $("#BCB2C1_DataModal").find('input');
	var selects = $("#BCB2C1_DataModal").find("select");
	var textareas = $("#BCB2C1_DataModal").find('textarea');
	var divs = $("div[id^='BCB2C1'][id$='FILE_div']");  
	$.each(inputs, function (i, obj) {
		$(obj).val("");
	});
	$.each(selects, function (i, obj) {
		$(obj).val("");
	});
	$.each(textareas, function (i, obj) {
		$(obj).val("");
	});
	$.each(divs, function (i, obj) {
		$(obj).html("");
	});
	/*清除输入框验证信息*/
	/*input validate clear begin*/
	
	/*input validate clear end*/
	BCB2C1_init_t_login_log();
}

//页面输入框赋值
function BCB2C1_get_edit_info(){
	var rowData = $("#ACB2C1_t_login_log_Events").bootstrapTable('getData')[ACB2C1_select_t_login_log_rowId];
	var inputs = $("#BCB2C1_DataModal").find('input');
	var selects = $("#BCB2C1_DataModal").find("select");
	var textareas = $("#BCB2C1_DataModal").find('textarea');
	
	//通用子页面输入框赋值
	Com_edit_info(rowData,inputs,selects,textareas,"ACB2C1","BCB2C1");
	
	//树型结构父类赋值
	/*tree pid set value begin*/

	/*tree pid set value end*/
	
	
	/*文件附件格式*/
	/*input param fileinfo begin*/
	
	/*input param fileinfo end*/
}

//form验证
function BCB2C1_checkFormInput() {
    BCB2C1_validate = $("#BCB2C1_DataModal").validate({
        errorElement: 'span',
        errorClass: 'help-block',
        rules: {
        	/*input check rules begin*/
            BCB2C1_MAIN_ID: {}
            ,BCB2C1_LOGIN_ID: {maxlength:50}
            ,BCB2C1_NICK_NAME: {maxlength:50}
            ,BCB2C1_OPE_IP: {maxlength:50}
            ,BCB2C1_SYS_DATE: {date: true,required : true,maxlength:19}
            ,BCB2C1_S_DESC: {maxlength:500}
            ,BCB2C1_CREATE_DATE: {date: true,required : true,maxlength:19}
			
            /*input check rules end*/
        },
        messages: {
        	/*input check messages begin*/
            BCB2C1_MAIN_ID: {}
            ,BCB2C1_LOGIN_ID: {maxlength:"长度不能超过50"}
            ,BCB2C1_NICK_NAME: {maxlength:"长度不能超过50"}
            ,BCB2C1_OPE_IP: {maxlength:"长度不能超过50"}
            ,BCB2C1_SYS_DATE: {date: "必须输入正确格式的日期",required : "必须输入正确格式的日期",maxlength:"长度不能超过19"}
            ,BCB2C1_S_DESC: {maxlength:"长度不能超过500"}
            ,BCB2C1_CREATE_DATE: {date: "必须输入正确格式的日期",required : "必须输入正确格式的日期",maxlength:"长度不能超过19"}
			
            /*input check messages end*/
        },
        errorPlacement: function (error, element) {
            element.next().remove();
            element.after('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>');
            element.closest('.form-group').append(error);
        },
        highlight: function (element) {
            $(element).closest('.form-group').addClass('has-error has-feedback');
        },
        success: function (label) {
            var el = label.closest('.form-group').find("input");
            el.next().remove();
            el.after('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>');
            label.closest('.form-group').removeClass('has-error').addClass("has-feedback has-success");
            label.remove();
        },
        submitHandler: function (form) {
        	BCB2C1_SubmitForm();
        	return false;
        }
    })
}